package com.example.waibao.service.impl;


import com.example.waibao.dao.materialMapper;
import com.example.waibao.entity.*;
import com.example.waibao.mapper.MaterialMapper2;
import com.example.waibao.service.materialService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class materialServiceImpl implements materialService {

    @Autowired
    private materialMapper materialMapper;

    @Autowired
    private MaterialMapper2 materialMapper2;
    @Override
    public void save_building(String img_name, String url, int school_id) {
        materialMapper.save_building(img_name, url,school_id);
    }

    @Override
    public PageInfo<building> get_building(String img_name, int school_id, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<building> all = materialMapper2.get_building(img_name, school_id);
        PageInfo<building> dataPageInfo = new PageInfo<>(all);
       return dataPageInfo;
    }

    @Override
    public List<building> getAllImg() {
        return materialMapper.getAllImg();
    }

    @Override
    public PageInfo<task> get_task(Integer pageNum, Integer pageSize, int taskId, int task_type_id) {
        PageHelper.startPage(pageNum,pageSize);
        List<task> all = materialMapper2.get_task(taskId, task_type_id);
        PageInfo<task> dataPageInfo = new PageInfo<>(all);
        return dataPageInfo;
    }

    @Override
    public void add_a_task(task task) {
        materialMapper.add_a_task(task.getTask_name(), task.getAward(), task.getRequire(),
                task.getScore(), task.getNeed(), task.getSchool_id(), task.getTask_type_id(),task.getArticle_id()
        ,task.getImg_url(),task.getSpeciality_id(),task.getWeight());
    }

    @Override
    public void add_task_place(int id, String place, int school_id) {
        materialMapper.add_task_place(id, place, school_id);
    }

    @Override
    public void save_map(String map, String modal, String scope, String legend, int school_id) {
        materialMapper.save_map(map, modal, scope, legend, school_id);
    }

    @Override
    public List<task_type> get_task_type() {
        return materialMapper.get_task_type();
    }

    @Override
    public List<task_place> get_task_place(String thePlace, int schoolId) {
        return materialMapper2.get_task_place(thePlace, schoolId);
    }

    @Override
    public List<task_type> get_task_type1(int i) {
        return materialMapper.get_task_type1(i);
    }

    @Override
    public void save_school_map(Object model, String map, Object schoolId, String area) {
        materialMapper.save_school_map(schoolId,model, map,area);
    }

    @Override
    public void save_school_map_legend(int i,String s, String s1, String s2, String s3, String s4, Object schoolId,String introduce_image,String introduce) {
        materialMapper.save_school_map_legend(i,s, s1, s2, s3, s4, schoolId,introduce_image,introduce);
    }

    @Override
    public school_map get_school_map(int schoolId) {
        return materialMapper.get_school_map(schoolId);
    }

    @Override
    public List<school_map_legend> get_school_map_legend(int schoolId) {
        return materialMapper.get_school_map_legend(schoolId);
    }

    @Override
    public List<article> get_article() {
        return materialMapper.get_article();
    }

    @Override
    public void delete_school_map(int schoolId) {
        materialMapper.delete_school_map(schoolId);
    }

    @Override
    public void delete_school_map_legend(int schoolId) {
        materialMapper.delete_school_map_legend(schoolId);
    }

    @Override
    public void delete_task(int id) {
        materialMapper.delete_task(id);
    }

    @Override
    public void update_task(task task) {
        materialMapper.update_task(task.getId(),task.getTask_name(), task.getAward(), task.getRequire(),
                String.valueOf(task.getScore()), task.getNeed(), task.getTask_type_id(),task.getArticle_id()
                ,task.getImg_url(),task.getSpeciality_id(),task.getWeight());
    }

    @Override
    public List<String> get_places(int id) {
        return materialMapper.get_places(id);
    }

    @Override
    public void delete_task_place(int taskId) {
        materialMapper.delete_task_place(taskId);
    }

//    @Override
//    public String get_task_place2(int t, int schoolId) {
//        return materialMapper.get_task_place2(t, schoolId);
//    }

//    @Override
//    public void add_task_place2(String thePlace, int taskId, int schoolId) {
//
//    }
}
